package com.example.shaomengjie.smvp.net.http;

import com.example.shaomengjie.smvp.bean.GuideBean;
import com.example.shaomengjie.smvp.bean.TestBean;
import com.example.shaomengjie.smvp.bean.UserBean;
import com.example.shaomengjie.smvp.net.api.ApiResponse;

import java.util.List;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.rx_cache2.EvictProvider;

/**
 * Created by shaomengjie on 2017/6/20.
 */

public class HttpMoudle extends BaseHttpMoudle{
    public void getDatasWithCache(int pno, int ps, String dtype, boolean update,Observer<TestBean> subscriber) {
        RxHelp.toSubscribe(cacheProvider.getDatas(mApiService.getDatas(pno, ps,dtype),new EvictProvider(update)), subscriber);
    }
    public void getDatasNoCache(int pno, int ps, String dtype,Observer<TestBean> subscriber) {
        Observable<ApiResponse<TestBean>> datas = mApiService.getDatas(pno, ps, dtype);
        RxHelp.toSubscribe(mApiService.getDatas(pno, ps,dtype), subscriber);
    }
    public void getGuideData(String mobile_type, Observer<List<GuideBean>> subscriber){
        RxHelp.toSubscribe(mApiService.requesetGuide(mobile_type),subscriber);
    }
    public void getLogion(String username,String password,Observer<UserBean> subscriber){
        RxHelp.toSubscribe(mApiService.requestLogin(username,password),subscriber);
    }
}
